/*
 * easy.cpp
 *
 *  Created on: 2024年9月4日
 *      Author: pengzc
 */

#include "easy.h"
#include <base/log.hpp>
#include <unistd.h>
#include <signal.h>

namespace http {

void curlInit() {
  CURLcode res = curl_global_init(CURL_GLOBAL_ALL);
  if (res != CURLE_OK) {
    LOGE_TRACE("CURL curl_global_init failed");
  }

  //忽略SIGPIPE
  struct sigaction sa;
  sa.sa_handler = SIG_IGN;
  sa.sa_flags = 0;
  if (sigemptyset(&sa.sa_mask) == -1 ||
      sigaction(SIGPIPE, &sa, 0) == -1) {
    LOGE_TRACE("failed ignore SIGPIPE");
  }
}

easy::easy() {
  curlInit();
}

easy::~easy() {
}

} /* namespace http */
